﻿SELECT 
	  d.INVENTLOCATIONID
	, i.NAME
	, SUM(d.AMOUNTSALE - d.RETURNAMOUNTSALE + d.OPTAMOUNTSALE) as Total 
FROM 
	RETAILCASHREPORTDETAILS d INNER JOIN INVENTLOCATION i 
		ON (i.INVENTLOCATIONID=d.INVENTLOCATIONID)AND(i.DATAAREAID='dat') 
WHERE 
	    (d.TRANSDATE='".$_POST["date"]."') 
	AND (d.DATAAREAID='dat') 
GROUP BY d.INVENTLOCATIONID, i.NAME 
ORDER BY i.NAME 


SELECT
	  d.TRANSDATE
	, d.INVENTLOCATIONID
	, i.NAME
	, SUM(d.AMOUNTSALE - d.RETURNAMOUNTSALE + d.OPTAMOUNTSALE) AS Total
FROM RETAILCASHREPORTDETAILS AS d 
	INNER JOIN INVENTLOCATION AS i ON i.INVENTLOCATIONID = d.INVENTLOCATIONID AND i.DATAAREAID = 'dat'
WHERE
	    (d.TRANSDATE = GETDATE()) 
	AND (d.DATAAREAID = 'dat')
GROUP BY d.TRANSDATE, d.INVENTLOCATIONID, i.NAME
ORDER BY i.NAME

